

USE [WebSecurity]
GO

GO
-- Drop stored procedure if it already exists
IF EXISTS (
  SELECT * 
    FROM INFORMATION_SCHEMA.ROUTINES 
   WHERE SPECIFIC_CATALOG = N'WebSecurity' 
	 AND SPECIFIC_SCHEMA = N'dbo'
     AND SPECIFIC_NAME = N'UserProfile_ins' 
)
   DROP PROCEDURE dbo.UserProfile_ins
GO
create procedure UserProfile_ins

	@UserId Int = null OUTPUT,
	@UserName NVarChar(30),
	@CreatedBy VarChar(50),
	@CreatedDt DateTime,
	@ModifiedBy VarChar(50),
	@ModifiedDt DateTime,
	@IsActive Bit,
	@FirstName NVarChar(50),
	@LastName NVarChar(50),
	@Address NVarChar(250),
	@City NVarChar(50),
	@Region NVarChar(50),
	@PostalCode NVarChar(25),
	@OfficePhone NVarChar(25),
	@CellPhone NVarChar(25),
	@Title NVarChar(100),
        @RowsAffected int = null OUTPUT 
	
--*************************************************************
--Created By: trooks
--Name: dbo_UserProfile_ins
--Schema: dbo
--Table: UserProfile
--Database: WebSecurity
--Created Date: 01/21/2013 00:00:00
--*************************************************************

as
	Begin Try
        insert into [dbo].UserProfile
		(
		UserName, 
		CreatedBy, 
		CreatedDt, 
		ModifiedBy, 
		ModifiedDt, 
		IsActive, 
		FirstName, 
		LastName, 
		Address, 
		City, 
		Region, 
		PostalCode, 
		OfficePhone, 
		CellPhone, 
		Title 
    )
    values
    (
		@UserName, 
		@CreatedBy, 
		@CreatedDt, 
		@ModifiedBy, 
		@ModifiedDt, 
		@IsActive, 
		@FirstName, 
		@LastName, 
		@Address, 
		@City, 
		@Region, 
		@PostalCode, 
		@OfficePhone, 
		@CellPhone, 
		@Title 
        )
		Set @UserId = SCOPE_IDENTITY(); 
		Set @RowsAffected = @@ROWCOUNT;
		return 0;	
	END TRY
	BEGIN CATCH
		Set @RowsAffected = 0;
		EXEC dbo.uspLogError;
		return -1;
	END CATCH
	
GO
GRANT EXECUTE ON [WebSecurity].[dbo].[UserProfile_ins] to PORTAL_WebSecurity
GO




